﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using PsychveyApp1.classes;

namespace PsychveyApp1
{
    public partial class ViewAllUser : System.Web.UI.Page
    {
        static UserAccount ua = new UserAccount();
        static ArrayList userlist = new ArrayList();

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PsychAppDBConnectionString"].ConnectionString);
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblAdminUsername.Text = (string)(Session["username"]);
                dgvUserDetails.DataBind();
                dgvUserDetails.Visible = true;

            }

        }

        public void FillUserGrid()
        {

            userlist = DBManager.GetSurveyByUserID(ua.userID);
            dgvUserDetails.DataSource = userlist;
            dgvUserDetails.DataBind();
            dgvUserDetails.Visible = true;
        }

        protected void dgvUserDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = dgvUserDetails.SelectedRow.RowIndex;
            dgvUserDetails.SelectedIndex.ToString();
            GridViewRow row = dgvUserDetails.SelectedRow;

            UserAccount us1 = new UserAccount();
            us1.userID = row.Cells[1].Text;
            us1.username = row.Cells[2].Text;
            us1.password = row.Cells[3].Text;
            us1.retypePassword = row.Cells[4].Text;
            us1.email = row.Cells[5].Text;
            us1.expirationDateForPremium = row.Cells[6].Text;
            us1.accountTypeSelected = row.Cells[7].Text;
            us1.paymentStatus = row.Cells[8].Text;
            us1.userFullName = row.Cells[9].Text;
            us1.paymentID = row.Cells[10].Text;
            us1.receiptID = row.Cells[11].Text;
            us1.planID = row.Cells[12].Text;

            Session["currentUser"] = us1;
            Response.Redirect("ViewAllUser.aspx");
        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            Response.Redirect("ViewAllSurvey.aspx");
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdminHome.aspx");
        }
            
        }

       

    }